package lab02.test26;

import java.util.Scanner;

public class ExceptionTest {
    /**
     * 在try块中，编写被0除的代码；
     * 在catch块中，捕获被0除所产生的异常，并且打印异常信息；
     * 在finally块中，打印一条语句
     */
    public static void main(String[] args) {
        int a = 0;
        int b = 0;
        Scanner scanner = new Scanner(System.in);
        while (true) {
            System.out.println("please input 1st int:");
            a = scanner.nextInt();
            System.out.println("please input 2nd int:");
            b = scanner.nextInt();
            int c = 0;
            try {
                c = a / b;
            } catch (ArithmeticException e) {
                System.out.println("除数为0！!!");
            } finally {
                System.out.println("最后都会执行的语句！！！");
            }
            System.out.println(a + "/" + b + "=" + c);
        }
    }
}
